//引用当前模块目的，主要是判断调用API的地址，当前crm,包括了crm,erp两个模块的地址，

import {
	myRequest,
	CRMURL
} from '@/utils/api.js'

//字典数据
export function apiModule() {

	let module = CRMURL;

	return module;

}

//字典数据
export function apiCstDict(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstDict/show_json', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//其它支出分类
export function apiFinExpensesType(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinExpensesType/show_json', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}
//其它收入分类
export function apiFinIncomeType(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinIncomeType/show_json', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//银行帐号
export function apiFinBankAccount(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinBankAccount/show_json', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}


//简报数据
export function apiWorkbench(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.Workbench/index', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}


//线索接口
export function apiClue(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstClue/show_json', postdata)
			break;
		case 'get_list_public':
			return myRequest(CRMURL + '/api.CstClue/show_public', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstClue/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstClue/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstClue/del', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstClue/detail', postdata)
			break;
		case 'goto_public':
			return myRequest(CRMURL + '/api.CstClue/gotopublic', postdata)
			break;
		case 'goto_personal':
			return myRequest(CRMURL + '/api.CstClue/gotopersonal', postdata)
			break;
		case 'goto_customer':
			return myRequest(CRMURL + '/api.CstClue/gotocustomer', postdata)
			break;
		case 'transfer':
			return myRequest(CRMURL + '/api.CstClue/transfer', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//线索跟进接口
export function apiClueTrace(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstClueTrace/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstClueTrace/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstClueTrace/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstClueTrace/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstClueTrace/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}



//客户管理
export function apiCustomer(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_customer_list':
			return myRequest(CRMURL + '/api.CstCustomer/show_json', postdata)
			break;
		case 'get_customer_search':
			return myRequest(CRMURL + '/api.CstCustomer/search_json', postdata)
			break;
		case 'get_list_public':
			return myRequest(CRMURL + '/api.CstCustomer/show_public', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstCustomer/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstCustomer/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstCustomer/del', postdata)
			break;
		case 'get_customer_detail':
			return myRequest(CRMURL + '/api.CstCustomer/detail', postdata)
			break;
		case 'goto_public':
			return myRequest(CRMURL + '/api.CstCustomer/gotopublic', postdata)
			break;
		case 'goto_personal':
			return myRequest(CRMURL + '/api.CstCustomer/gotopersonal', postdata)
			break;
		case 'allot':
			return myRequest(CRMURL + '/api.CstCustomer/allot', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}
// 客户联系人
export function apiLinkman(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstLinkman/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstLinkman/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstLinkman/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstLinkman/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstLinkman/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}
// 跟进记录
export function apiTrace(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstTrace/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstTrace/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstTrace/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstTrace/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstTrace/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//销售机会
export function apiChance(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstChance/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstChance/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstChance/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstChance/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstChance/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//报价单
export function apiQuoted(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.CstQuoted/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.CstQuoted/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.CstQuoted/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.CstQuoted/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.CstQuoted/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.CstQuoted/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//销售合同
export function apiSalContract(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SalContract/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.SalContract/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.SalContract/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.SalContract/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.SalContract/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SalContract/del', postdata)
			break;

		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//销售订单
export function apiSalOrder(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SalOrder/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.SalOrder/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.SalOrder/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.SalOrder/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.SalOrder/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SalOrder/del', postdata)
			break;

		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//收款记录
export function apiFinReceRecord(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinReceRecord/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinReceRecord/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinReceRecord/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinReceRecord/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinReceRecord/del', postdata)
			break;

		case 'audit':
			return myRequest(CRMURL + '/api.FinReceRecord/audit', postdata)
			break;

		case 'cancel':
			return myRequest(CRMURL + '/api.FinReceRecord/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//付款记录
export function apiFinPayRecord(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinPayRecord/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinPayRecord/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinPayRecord/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinPayRecord/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinPayRecord/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.FinPayRecord/audit', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.FinPayRecord/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//开票记录
export function apiFinInvoicePay(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinInvoicePay/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinInvoicePay/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinInvoicePay/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinInvoicePay/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinInvoicePay/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.FinInvoicePay/audit', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.FinInvoicePay/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//收票
export function apiFinInvoiceRece(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinInvoiceRece/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinInvoiceRece/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinInvoiceRece/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinInvoiceRece/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinInvoiceRece/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.FinInvoiceRece/audit', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.FinInvoiceRece/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//其它支出记录
export function apiFinExpensesRecord(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinExpensesRecord/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinExpensesRecord/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinExpensesRecord/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinExpensesRecord/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinExpensesRecord/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.FinExpensesRecord/audit', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.FinExpensesRecord/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}


//其它收入记录
export function apiFinIncomeRecord(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.FinIncomeRecord/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.FinIncomeRecord/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.FinIncomeRecord/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.FinIncomeRecord/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.FinIncomeRecord/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.FinIncomeRecord/audit', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.FinIncomeRecord/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}


//供应商管理
export function apiSupSupplier(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SupSupplier/show_json', postdata)
			break;
		case 'get_list_public':
			return myRequest(CRMURL + '/api.SupSupplier/show_public', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.SupSupplier/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.SupSupplier/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.SupSupplier/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SupSupplier/del', postdata)
			break;
		case 'goto_public':
			return myRequest(CRMURL + '/api.SupSupplier/gotopublic', postdata)
			break;
		case 'goto_personal':
			return myRequest(CRMURL + '/api.SupSupplier/gotopersonal', postdata)
			break;
		case 'allot':
			return myRequest(CRMURL + '/api.SupSupplier/allot', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}
// 供应商联系人
export function apiSupLinkman(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SupLinkman/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.SupLinkman/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.SupLinkman/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.SupLinkman/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SupLinkman/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//采购合同
export function apiPosContract(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.PosContract/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.PosContract/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.PosContract/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.PosContract/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.PosContract/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.PosContract/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.PosContract/sure', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.PosContract/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//仓库管理
export function apiStockStore(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.StockStore/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.StockStore/detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.StockStore/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.StockStore/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.StockStore/del', postdata)
			break;
		case 'enable':
			return myRequest(CRMURL + '/api.StockStore/set_visible', postdata)
			break;
		case 'disable':
			return myRequest(CRMURL + '/api.StockStore/set_visible', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//出库单
export function apiStockOut(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.StockOut/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.StockOut/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.StockOut/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.StockOut/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.StockOut/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.StockOut/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.StockOut/sure', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.StockOut/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//出库单
export function apiStockInto(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.StockInto/show_json', postdata)
			break;
		case 'get_detail':
			return myRequest(CRMURL + '/api.StockInto/detail', postdata)
			break;
		case 'get_list_detail':
			return myRequest(CRMURL + '/api.StockInto/get_list_detail', postdata)
			break;
		case 'add':
			return myRequest(CRMURL + '/api.StockInto/add', postdata)
			break;
		case 'update':
			return myRequest(CRMURL + '/api.StockInto/edit', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.StockInto/del', postdata)
			break;
		case 'audit':
			return myRequest(CRMURL + '/api.StockInto/sure', postdata)
			break;
		case 'cancel':
			return myRequest(CRMURL + '/api.StockInto/cancel', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}